﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;

namespace Axe.Data.Mapping
{
    public static class Difference
    {
        public static List<String> GetDiff<T>(T a, T b) where T : class
        {
            List<String> diff = new List<string>();

            MappingDescription mDescr = MappingDescriptionBuilder.GetDescription(typeof(T));
            
            foreach(PropertyDescription prop in mDescr.MappedFields.Values)
            {
                object left = prop.GetValue(a);
                object right = prop.GetValue(b);
                bool isEq = Utility.TrueEquals(left, right);
                
                if (!isEq)
                {
                    diff.Add(prop.PropertyName);
                }
            }

            return diff;
        }
    }
}
